package com.koron.css2.systemManage.servlet;

import com.koron.css2.ApplicationConfig;
import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.systemManage.bean.RoleBean;
import com.koron.css2.systemManage.service.IRoleService;
import com.koron.css2.systemManage.service.ServiceFactory;
import com.koron.util.Constant;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;

/**
 * 角色列表
 * @author 59532
 *
 */
public class PubRoleList implements ServerInterface{
	
	private static Logger log = LogManager.getLogger(PubRoleList.class);

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		MessageBean<List> msg = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "查詢成功", List.class);
		try {
			IRoleService service = ServiceFactory.getRoleService();
			List<RoleBean> roles = service.listRole(ApplicationConfig.getAppCustomerAppid());
			msg.setData(roles);
		}catch(Exception ex) {
			log.error("查詢角色列表出错：" + ex);
			msg.setCode(Constant.MESSAGE_INT_FAIL);
			msg.setDescription("查詢角色列表出错");
		}
		return msg;
	}
}
